//
//  TTVerifyLoginView.m
//  TaoTuo
//
//  Created by admin on 2019/8/15.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTVerifyLoginView.h"

@implementation TTVerifyLoginView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self phoneTF];
        [self verifyTF];
        [self verifyBtn];
        
        [LLLineUtilies addLineInView:self startPoint:CGPointMake(0, self.verifyTF.bottom - 1) endPoint:CGPointMake(self.width, self.verifyTF.bottom - 1) lineColor:UIColorHex(EDEDED)];
        
    }
    return self;
}

- (LLTextField *)phoneTF
{
    if (!_phoneTF) {
        _phoneTF = [[LLTextField alloc] initWithFrame:CGRectMake(0, 0, self.width, 45)];
        _phoneTF.leftImageName = @"zhanghao";
        [_phoneTF setPlaceholder:@"请输入手机号" lightColor:nil darkColor:nil];
        _phoneTF.textColor = [UIColor blackColor];
        _phoneTF.keyboardType = UIKeyboardTypeNumberPad;
        [self addSubview:_phoneTF];
    }
    return _phoneTF;
}


- (LLTextField *)verifyTF
{
    if (!_verifyTF) {
        _verifyTF = [[LLTextField alloc] initWithFrame:CGRectMake(0, self.phoneTF.bottom + 15, self.width - 120, 45)];
        [_verifyTF setPlaceholder:@"请输入验证码" lightColor:nil darkColor:nil];
        _verifyTF.font = [UIFont systemFontOfSize:15];
        _verifyTF.keyboardType = UIKeyboardTypeNumberPad;
        _verifyTF.textColor = [UIColor blackColor];
        _verifyTF.leftImageName = @"yanzhengma";
        [self addSubview:_verifyTF];
        
    }
    return _verifyTF;
}

- (LLCountDownButton *)verifyBtn
{
    if (!_verifyBtn) {
        _verifyBtn = [[LLCountDownButton alloc] initWithFrame:CGRectMake(self.verifyTF.right, self.verifyTF.top, 120, self.verifyTF.height)];
        [_verifyBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
        _verifyBtn.normalTitleColor = kMainColor;
        _verifyBtn.disableTitleColor = [UIColor grayColor];
        _verifyBtn.normalBorderColor = [UIColor whiteColor];
        _verifyBtn.disableBorderColor = [UIColor whiteColor];
        [self addSubview:_verifyBtn];
        
        @weakify(self)
        _verifyBtn.countDownFinished = ^(LLCountDownButton * _Nonnull btn) {
            @strongify(self)
            btn.enabled = self.phoneTF.text.length >= 13;
        };
    }
    return _verifyBtn;
}


@end
